//
//  UIButton+YWExtention.swift
//  demo02
//
//  Created by 陈友文 on 2021/1/22.
//

import UIKit


extension UIButton{
    convenience init(title:String,
                     imgName:String = "",
                     bgColor:UIColor = UIColor.white,
                     bgImg:String = "",
                     cornerRadius:CGFloat = 5,
                     state:UIControl.State = .normal,
                     titleColor:UIColor = UIColor.black,
                     isClip:Bool = false,
                     target:Any?,
                     action:Selector,
                     event:UIControl.Event
                     ){
        self.init()
        setTitle(title, for: .normal)
        setImage(UIImage(named: imgName), for: state)
        setBackgroundImage(UIImage(named: bgImg), for: state)
        backgroundColor = bgColor
        layer.cornerRadius = cornerRadius
        setTitleColor(titleColor, for: state)
        clipsToBounds = isClip
        addTarget(target, action: action, for: event)
    }
}
